﻿using System;
using Microsoft.SharePoint;

namespace SKN
{
    /// <summary>
    /// Contains common method for Features
    /// </summary>
    public static class Features
    {
        ///<summary>
        /// Use this method to activate feature at site collection level
        /// </summary>
        ///<param name="site"></param>
        ///<param name="featureGuid"></param>
        public static void ActivateSiteCollectionFeature(SPSite site, Guid featureGuid)
        {
            site.Features.Add(featureGuid, true);
        }

        /// <summary>
        /// Use this method to de-activate feature at site collection level
        /// </summary>
        /// <param name="site"></param>
        /// <param name="featureGuid"></param>
        public static void DeactivateSiteCollectionFeature(SPSite site, Guid featureGuid)
        {
            site.Features.Remove(featureGuid, true);
        }

        /// <summary>
        /// Use this method to activate feature at web level
        /// </summary>
        /// <param name="web"></param>
        /// <param name="featureGuid"></param>
        public static void ActivateWebFeature(SPWeb web, Guid featureGuid)
        {
            web.Features.Add(featureGuid, true);
            web.Update();
        }

        /// <summary>
        /// Use this method to de-activate feature at web level
        /// </summary>
        /// <param name="web"></param>
        /// <param name="featureGuid"></param>
        public static void DeactivateWebFeature(SPWeb web, Guid featureGuid)
        {
            web.Features.Remove(featureGuid, true);
            web.Update();
        }
    }
}